package com.java.sjzl.test;

public class test1 {

    public static void main(String[] args) {
        // 示例用法
        String date1 = "2024-01-02 23:00:00";
        String date2 = "2024-01-02";

        String result = areDatesEqual(date1, date2);
        System.out.println("Dates are equal: " + result);
    }
    public static String areDatesEqual(String str1, String str2) {
        // 判断输入是否为空
        if (str1 == null || str2 == null || str1.trim().isEmpty() || str2.trim().isEmpty()) {
            return Boolean.toString(false);
        }
        // 截取日期部分进行比较
        String date1 = str1.trim().substring(0, 10);
        String date2 = str2.trim().substring(0, 10);
        // 判断日期是否相等
        return Boolean.toString(date1.equals(date2));
    }
}
